package demo2;

//最大子矩阵和--二维前缀和版本

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[][] map = new int[n][n];
        for(int i = 0; i<n; i++) {
            for(int j = 0; j<n; j++) {
                map[i][j] = in.nextInt();
            }
        }
        int[][] s = new int[n+1][n+1];
        for(int i = 1; i<=n; i++) {
            for(int j = 1; j<=n; j++) {
                s[i][j] = s[i-1][j] + s[i][j-1] - s[i-1][j-1] + map[i-1][j-1];
                //System.out.print(s[i][j] + "  ");
            }
            //System.out.println();
        }

        int ret = Integer.MIN_VALUE;
        for(int y1 = 0; y1 < n; y1++) {
            for(int x1 = 0; x1 < n; x1++) {
                for(int y2 = y1+1; y2 <= n; y2++) {
                    for(int x2 = x1+1; x2 <= n; x2++) {
                        int sum = s[x2][y2] - s[x2][y1] - s[x1][y2] + s[x1][y1];
                        ret = Math.max(sum,ret);
                    }
                }
            }
        }

        System.out.println(ret);
    }
}